<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="../static/css/bootstrap.css" />
	<!--需要在Javascript之前引入JQuer-->
	<script type="text/javascript" src="../static/js/jquery-1.11.0.js"></script>
	<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
	<script type="text/javascript" src="../static/js/bootstrap.js"></script>
	<!--针对移动设备的样式，为了确保适当的绘制和触屏缩放-->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!--jquery.cookie.js-->
	<script src="../static/js/jquery.cookie.js"></script>
</head>
	<body style=" color: #7d8b8d;background: #f0eef5;">
	<div class="bgcolor bgcolor_open">
		<style>
			.bgcolor_open{background-color: #eee;}
			.bgcolor_close{background-color: #555;}
		</style>
	    <div class="row clearfix">
	        <div class="col-md-12 column">
				<div class="row clearfix" title="top_img">
					<div class="col-md-12 column">
						<img src="../static/img/header.png" width="100%" height="80px" />
					</div>
				</div>
	            <div class="row clearfix" title="top">
	                <div class="col-md-12 column">
	                	<!--头部-->
	                	<nav class="navbar-inverse container-fluid" role="navigation" style="background-color: #444;">
							<div class="container-fluid" style="padding: 0 30px 0 30px;"> 
						    <div class="navbar-header">
						        <a class="navbar-brand" href="/content/detail">
						        	<font color="#F9F9F9">留言part</font>
						        </a>
						    </div>
						    <div>
						        <!--向左对齐-->
						        <ul class="nav navbar-nav navbar-left">
						            <li class="dropdown">
						                <a href="/content/detail">
						                    首页
						                    <b class="caret"></b>
						                </a>
						                
						            </li>
						        </ul>
						       <!-- 向左对齐-文本-->
						        <!--向右对齐-->
						         <ul id="nav_right" class=" nav navbar-nav navbar-right">
				                    <li class="dropdown" style="display: none;">
				                        <form class="navbar-form navbar-right" >
									        <div class="form-group">
									         <div class="input-group">
									          <input type="text" class="form-control" placeholder="代码改变世界" style="border-radius:25px;">
									          <span class="input-group-btn" style="right:40px">
									          	<button type="submit" class="btn btn-default" style="border: none;background: none;">
									          	<span class="glyphicon glyphicon-search">
									          	</span>
									            </button>
									          </span>
									          </div>
									        </div>
									    </form>
				                    </li>
				                    <li>
										<a href="#" class="Inform" style="">
											<span class="badge" style='background-color: red;' ></span>
											<span  class="glyphicon glyphicon-bell" style="font-size: 18px;"></span>
										</a>
				                    </li>
									 <script>
										 //Bell按钮
										 Bell();
										 function Bell() {
											 var login_username = $.cookie("login_username");
											 var url = "/message/listapt"
											 $.get(url, {user_name: login_username}, function (AptData) {
												 console.log(AptData);
												 //获取点赞的文章数组
												 var arr_M = [];
												 for (var m in AptData.thumbupList) {
													 var M_val = AptData.thumbupList[m].Message_id;
													 arr_M.push(M_val);
												 }
												 // console.log(arr_M)
												 var status_arr =[];
												 var staNum =[];
												 for (p in AptData.List_Apt){
													 //判断状态状态是否已查
													 var status_ = Number(AptData.List_Apt[p].Status);
													 if (status_ == 0) {
														 var msg_id = AptData.List_Apt[p].Message_id;
														 //获取每一篇文章的点赞数
														 var Num = []
														 Num = jQuery.grep(arr_M, function( n, index ) {
															 return ( n == msg_id);
														 });
														 var href="/basetext?msg_id="+msg_id+"&num="+Num.length+"";
														 $(".Inform").attr("href",href);
														 // //修改状态
														 // $.ajax({
														 //  type: "POST",
														 //  url: "http://127.0.0.1:8080/upsta",
														 //  data: {c_id: AptData.List_Apt[i].Id, sta: 1},
														 //  success: function (s) {
														 // 	 console.log("状态已经改变" + s)
														 //  }
														 // });
													 }
													 //未回复的数量
													 status_arr.push(AptData.List_Apt[p].Status);
												 }
												 staNum = jQuery.grep(status_arr, function( n, index ) {
													 return ( n == 0);
												 });
												 if (staNum.length > 0){
													 $(".badge").html(""+staNum.length+"");
												 }else {
													 $(".badge").css("display","none");
												 }
											 });

										 }
									 </script>

				                    <li class="dropdown">
						                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
						                    <span class="glyphicon glyphicon-user" style="font-size: 17px;"></span>
						                    <b class="caret"></b>
						                </a>
						                <ul class="dropdown-menu">
											<li><a href="#" onclick="PersonalInfo()">个人信息</a></li>
											<li>
												<a onclick="BgColor()"><button id="BgSwitch" style="background: none; border: none">关灯（夜）</button></a>
											</li>
						                    <li class="divider"></li>
											<li><a href="#" id="LoggingOut" onclick="LoggingOut()">退出登录</a></li>
						                </ul>
						            </li>
				                </ul>
						       <!-- 向右对齐-文本-->
						    </div>
							</div>
						</nav>
						<!--头部-->
	                </div>
	            </div>
				<script>
					// 开灯关灯按钮
					function BgColor(){
						$(".bgcolor").toggleClass("bgcolor_open");
						$(".bgcolor").toggleClass("bgcolor_close");
						$(".bgcolor_msg").toggleClass("bgcolor_close");
						$(".bgcolor_msg").toggleClass("bgcolor_open");
						var val_len = $(".bgcolor").attr("class").length;
						if (val_len >20){
							$("#BgSwitch").html("开灯（昼）");
						}else {
							$("#BgSwitch").html("关灯（夜）");
						}
					}
				</script>
	            <div class="row clearfix" title="top_img">
					<div class="col-md-12 column">
						<img src="../static/img/t1.png" width="100%" height="30px" />
					</div>
				</div>
				<div class="container" >
					<div class="row clearfix " title="main" style="background: white;">
						<div class="col-md-12 column">
							<!--信息内容-->
							<div class="row clearfi" style="padding: 0 15px;">
								<h1>
									<span class="glyphicon glyphicon-earphone">： 联系管理员</span>
								</h1>
							</div>
							<!--信息内容-->
							<!--作者列表-->
							<div class="list-group-item" style="border-left: none; border-right: none;">
								<article>
									<section >
										<div id="LinkAdmin" >
											<div class="row clearfix">
												<div class="col-md-12 column">
													<p>回复:</p>
													<p><textarea id="link_content" class="form-control" rows="3" autofocus="autofocus" placeholder="简介......"  style=" border-top:hidden; border-left:hidden ; border-right:hidden ;"></textarea></p>
												</div>
												<div class="col-md-2" style="float: right;">
													<button onclick="Link()" class="btn btn-block btn-group-lg btn-info">发送</button>
												</div>
											</div>
										</div>
									</section>
									<figure>
									</figure>
								</article>
							</div>
							<!--作者列表-->
						</div>
					</div>
					<script>
						//个人资料按钮
						function PersonalInfo() {
							var userId = $.cookie("userId");
							var href = "/user?status=1&id=" + userId;
							window.location.replace(href);
						}
						//退出登录
						function LoggingOut() {
							$.removeCookie("userId");
							$.removeCookie('headpic');
							$.removeCookie('login_username');
							$.removeCookie('aut_name');
							$.removeCookie('msg_id');
							$.removeCookie('num');
							// $.cookie('userId', null);
							window.location.replace("/login");
						}
					</script>
					<script>
						$(function () {
							//登录用户名
							var login_username = $.cookie("login_username");
							//判断是否是超级用户
							if ("admin"== login_username){
								$("#LinkAdmin").prop({
									hidden : true,
								});

							}

						});
						// 联系管理员
						function Link() {
							//登录用户名
							var login_username = $.cookie("login_username");
							//内容id和内容
							var content =$("#link_content").val();
							var url_ ="/link";
							$.post(url_,{sender:login_username,accepter:"admin",content:content},function (One,Sta_) {
								console.log(One);
								alert("发送成功！");
								window.location.reload();
							});
						}
					</script>
					<div class="row clearfix;" style="height: 30px;"></div>
					<div class="row clearfix " title="main" style="background: white;">
						<div class="col-md-12 column" style="background: white;">
							<!--评论列表-->
							<div style="margin-top: 20px;border-bottom: 2px solid #8C8C8C;"><font size="4">联系内容列表</font></div>
							<div class="list-group-item Link" style="border-left: none; border-right: none;">
								<!--列表内容-->
								<article>
									<section >
										<div hidden>
											<div class="row clearfix">
												<div class="col-md-12 column">
													<div class="media">
													<span style="padding-left: 10px;">
													  	<span style="color: #337ab7;">#<span>1</span>楼</span>
													  	<span id="send_time">2021-01-24 20:04</span>
										                 <span id="accept_name" user_id="1" style="color: #337ab7;">清风紫雪</span>
										                 <span style="float: right;">
													  	   <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" style='text-decoration:none;'><button onclick="reply()" style="background: none; border: hidden;">回复</button></a>
										                 </span>
										            </span>
														<div class="media-body">
														 <span style="padding: 10px 20px;">
														  	解放后设法是
											             </span>
															<br />
															<span style="float: right;">
														  	<a href="#" style='text-decoration:none;'>支持（0）</a> <a href="#" style='text-decoration:none;'>反对（0）</a>
											             </span>
														</div>
													</div>
													<div class="panel panel-default">
														<div id="collapseOne" class="panel-collapse collapse">
															<div class="panel-body">
																<div class="col-md-10">
																	<textarea id="content_id" class="form-control" rows="1" placeholder="简介......"  style=" border-top:hidden; border-left:hidden ; border-right:hidden ;"></textarea>
																</div>
																<div class="col-md-2">
																	<button type="button"  class="btn btn-block btn-group-lg btn-info">发送</button>
																</div>
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
									</section>
								</article>
								<!--列表内容-->
							</div>
							<!--评论列表-->
							<script type="text/javascript">
								//遍历link列表
								$(function () {
									//登录用户名
									var login_username = $.cookie("login_username");
									var url = "/link/list"
									$.get(url, {name: login_username}, function (LinkData) {
										console.log(LinkData);
										$(".Link").empty();
										var trhtml = "";
										if (LinkData.LinktList.length == 0){
											$(".Critic").html("<h4>暂无评论......</h4>");
										}else {
											for ( i in LinkData.LinktList){
												var accepter = LinkData.LinktList[i].Accepter;
												var accept_name = "@"+accepter+"~：";
												//判断评论者与登录用户的用户名是否相同
												if(LinkData.LinktList[i].Sender == login_username){
													var effect1 = "hidden";
													var effect2 = "";
												}else {
													effect1 ="";
													effect2 = "hidden";
												}
												var effect3 ="hidden";
												//判断登录者与被评论者
												if(login_username == accepter){
													//判断状态状态是否已查
													var status = Number(LinkData.LinktList[i].Status);
													if (status == 0) {
														//修改状态
														$.ajax({
															type: "POST",
															url: "/link/status",
															data: {id:LinkData.LinktList[i].Id,sta:1},
															success: function (s) {
																console.log("状态已经改变"+s)
															}
														});
														effect3 = "";
													}
												}
												//判断是否是超级用户
												if ("admin"== login_username){
													 effect1 = "";
													 effect2 = "";
												}
												var l = parseInt(i)+1;
												trhtml +="<!--列表内容-->" +
												"<article>" +
												"<section >" +
												"<div >" +
												"<div class=\"row clearfix\">" +
												"<div class=\"col-md-12 column\">" +
												"<div class=\"media\">" +
												"<span style=\"padding-left: 10px;\">" +
												"<span style=\"color: #337ab7;\">" +
												"<a href=\"#\" "+effect3+">"+
												"<span class=\"badge\" style='background-color: red;' >" +
												"<span class=\"glyphicon glyphicon-bell\" style=\"color: white;\"></span>" +
												"</span> " +
												"</a>"+
												"# <span>"+l+"</span> 楼 </span>" +
												"<span id=\"send_time\">"+LinkData.LinktList[i].Sd_time+"</span>" +
												"<span id=\"accept_name_"+l+"\" style=\"color: #337ab7;\"> "+LinkData.LinktList[i].Sender+" </span>" +
												"<span id=\"span_"+l+"\" style=\"float: right;\" >" +
												"<a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#collapse"+l+"\" style='text-decoration:none;' "+effect1+">" +
												"<button id='btn"+l+"' class='btn' onclick='document.getElementById(\"content_"+l+"\").placeholder=\"@"+LinkData.LinktList[i].Sender+"\"' style=\"background: none; border:none;\">回复</button>" +
												"</a>" +
												"<a href=\"#\" onclick='Trash("+LinkData.LinktList[i].Id+")' "+effect2+">"+
												"<button class='btn' style=\"background: none; border:none;\">删除</button>" +
												"</a>" +
												"</span>" +
												"</span>" +
												"<div class=\"media-body\">" +
												"<span style=\"padding: 20px 20px;\">"+accept_name+"“"+LinkData.LinktList[i].Content+"”</span><br/>" +
												"</div>" +
												"</div>" +
												"<div class=\"panel panel-default\">" +
												"<div id=\"collapse"+l+"\" class=\"panel-collapse collapse\">" +
												"<div class=\"panel-body\">" +
												"<div class=\"col-md-10\">" +
												"<textarea id=\"content_"+l+"\" class=\"form-control\" rows=\"1\" placeholder=\"简介......\"  style=\" border-top:hidden; border-left:hidden ; border-right:hidden ;\"></textarea>" +
												"</div>" +
												"<div class=\"col-md-2\">" +
												"<button  content_id=\"content_"+l+"\" accept_name=\""+LinkData.LinktList[i].Sender+"\" class=\"btn btn-block btn-group-lg btn-info\" id=\"Reply\">发送</button>" +
												"</div>" +
												"</div>" +
												"</div>" +
												"</div>" +
												"</div>" +
												"</div>" +
												"</div>" +
												"</section>" +
												"</article>" +
												"<!--列表内容-->";

											};
											$(".Link").html(trhtml);
											// 回复评论
											$("[id=Reply]").click(function (){
												//接收者用户名
												var accept_name = $(this).attr("accept_name");
												//内容id和内容
												var content_id =$(this).attr("content_id");
												var content = $("#"+content_id).val();
												var url_ ="/link";
												$.post(url_,{sender:login_username,accepter:accept_name,content:content},function (One,Sta_) {
													console.log(One);
													alert("发送成功！");
													window.location.reload();
												});
											});
										}
									});
								});
								//删除历史公告
								function Trash(id) {
									var DelUrl = "/link/del?id="+id;
									$.post(DelUrl,function () {
										alert("删除成功！");
										window.location.reload();
									})
								}
							</script>
						</div>
					</div>
					<div class="row clearfix ">
						<div class="col-md-12 column ">
							<p>
								<a href="#"  class="btn btn-default btn-md navbar-right goTop-hook" role="button">返回顶部</a>
								<script>
									// 点击返回顶部
									$(window).scroll(function() {
										if ($(window).scrollTop() >= 100) {
											$(".goTop-hook").fadeIn(300)
										} else {
											$(".goTop-hook").fadeOut(300)
										}
									})

									$(".goTop-hook").bind("click", function() {
										$("html").animate({ scrollTop: 0 }, 300)
									})
									function refresh() {
										window.location.reload();//刷新当前页面.

										//或者下方刷新方法
										//parent.location.reload()刷新父亲对象（用于框架）--需在iframe框架内使用
										//opener.location.reload()刷新父窗口对象（用于单开窗口)
										//top.location.reload()刷新最顶端对象（用于多开窗口）
									}
								</script>
								<a href="#" onclick="refresh()" class="btn btn-default btn-md navbar-right" role="button">刷新页面</a>
							</p>
						</div>
					</div>
				</div>

	            <div class="row clearfix" title="footer">
					<div class="col-md-12 column">
						<footer id="footer" class="footer">\
							<center>
				            <div id="friend_link" class="">
							    友情链接：
							    <a href="//www.vpsor.cn" target="_blank">硅云</a>
							    <a href="//aws.amazon.com" target="_blank">AWS</a>
							    <a href="//www.aliyun.com" target="_blank">阿里云</a>
							    <a href="//cloud.tencent.com" target="_blank">腾讯云</a>
							    <a href="//www.huaweicloud.com" target="_blank">华为云</a>
							    <a href="//cloud.baidu.com" target="_blank">百度云</a>
							    <a href="//www.jdcloud.com" target="_blank">京东云</a>
							    <a href="//www.163yun.com" target="_blank">网易云</a>
							    <a href="//www.yisu.com" target="_blank">亿速云</a>
							    <a href="//www.rongcloud.cn" target="_blank">融云</a>
							    <a href="//www.shanhaibi.com/" target="_blank">山海鲸可视化</a>
							    <a href="http://www.gcpowertools.com.cn" target="_blank">葡萄城控件</a>
							    <a href="//www.chinaz.com/" target="_blank">站长之家</a>
							    <a href="http://dev.yesky.com" target="_blank">天极网</a>
							    <a href="//wetest.qq.com/?from=links_cnblogs" target="_blank">腾讯WeTest</a>
							    <a href="http://www.ucancode.com/" target="_blank">工控组态源码</a>
							</div>
				            <div class="footer-splitter" style="margin-top: 10px;margin-bottom: 20px;width: 80%;height: 1px;background-color: #999;"></div>
				            </center>
				        </footer>
					</div>
				</div>
	        </div>
	    </div>
	</div>
	</body>
</html>
